<template>
  <div style="margin: 20px">
    <div>{{$t('ajax')}}</div>
    <a-button type="primary" @click="getSubjects"> 获取课程信息 </a-button>
    <!-- <a-button type="primary" @click="delSubject(2)"> 删除年级信息 </a-button> -->
    <div v-for="(item, index) in Subjects" :key="index">
      {{ item }}
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 课程数组
      Subjects: [],
      // 年级数组
      Grades: [],
      // 编辑框是否为添加状态
      isAdd: true,
      // 课程对象
      subject: {
        subjectId: 0,
        subjectName: '',
        classHour: 0,
        gradeId: 1
      },
      // 是否显示编辑框窗口
      isShow: false
    }
  },

  methods: {
    // 获取课程信息
    async getSubjects () {
      const url = this.$config.api.GetAll
      const res = await this.$http.get(url)
      console.log(res)
      this.Subjects = res
    }
    // 删除课程
    // async delSubject(SubjectId) {
    //   const url = this.$config.api.Delete;
    //   const res = await this.$http.post(url, SubjectId);
    //   console.log(res);
    //   if (res) {
    //     alert("删除成功");
    //   }
    // },

  }
}
</script>
<style>
</style>
